﻿using Mapster;
using WeChatV3Pay.Application.Transactions.Dtos.JsApi;

namespace WeChatV3Pay.Application.Refunds.Dtos
{
    public class Mapper : IRegister
    {
        public void Register(TypeAdapterConfig config)
        {
            config.ForType<RefundsReq, RefundsDto>()
                .Map(dest => dest.FundsAccount, src => !string.IsNullOrWhiteSpace(src.FundsAccount) ? src.FundsAccount : null)
                .Map(dest => dest.GoodsDetail, src => (src.GoodsDetail != null && src.GoodsDetail.Any()) ? src.GoodsDetail : null)
                .Map(dest => dest.TransactionId, src => !string.IsNullOrWhiteSpace(src.TransactionId) ? src.TransactionId : null);
        }
    }
}
